import { defineConfig } from "vite";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import vue from "@vitejs/plugin-vue";
import path from "path";

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue", "vue-router"],
      include: [/\.vue$/, /\.ts$/],
      // 生成auto-import.d.ts声明文件
      dts: "types/auto-imports.d.ts",
      /**自动导入目录的路径 */
      dirs: ["src/composables"],
      resolvers: [ElementPlusResolver({})],
    }),
    Components({
      dts: "types/components.d.ts",
      dirs: ["src/components"],
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: [
      {
        find: "@",
        replacement: path.resolve(__dirname, "./src"),
      },
    ],
  },
});
